package com.wlyuan.open.infrastructure.utils;

import com.wlyuan.mybatis.utils.BatchHandlerUtil;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.SqlSessionUtils;

import java.util.List;
import java.util.function.BiConsumer;

/**
 * @author lijing
 */
public class BatchMybatisUtil {

    public static <M, T> void batchHandler(SqlSessionFactory sqlSessionFactory,
                                           List<T> list, Class<M> clazz, BiConsumer<M, T> biConsumer) {
        BatchHandlerUtil.batchHandler(sqlSessionFactory, list, clazz, biConsumer);
        SqlSessionUtils.getSqlSession(sqlSessionFactory).clearCache();
    }
}
